package part19;

/**
 * @author wcj
 * @Date 2021/6/5 16:40
 * @Version 1.0
 */
public class Part191 {

    /**
     * 枚举的基本特性：ordinal返回次序，Enum实现了Comparable接口和Serializable接口
     *
     * @param args
     */
    public static void main(String[] args) {
        for (Shrubbery value : Shrubbery.values()) {
            System.out.println("ordinal:" + value.ordinal());
            System.out.println(value.compareTo(Shrubbery.CRAWLING));
            System.out.println(value.equals(Shrubbery.CRAWLING));
            System.out.println(value == Shrubbery.CRAWLING);
            System.out.println(value.getDeclaringClass());
            System.out.println(value.name());
        }

        for (String s : "GROUND CRAWLING HANGING".split(" ")) {
            Shrubbery shrub = Enum.valueOf(Shrubbery.class, s);
            System.out.println(shrub);
        }
    }
}

enum Shrubbery {
    /**
     * GROUND
     */
    GROUND,

    /**
     * CRAWLING
     */
    CRAWLING,

    /**
     * HANGING
     */
    HANGING
}
